var lng_letcomment_pic 		= 'Hãy viết gì đó về bức hình này...';
var lng_letlocation_pic 	= 'Hãy nhập vào địa danh nơi bạn chụp ảnh này...';
var lng_a_comment			= 'Viết bình luận cho hình ảnh này';
var lng_a_location			= 'Địa điểm chụp hình này';
var lng_a_friend			= 'Thêm những người bạn có mặt trong ảnh này';
var lng_letinput_username 	= 'Nhấn vào đây và nhập tên tài khoản của bạn bè có mặt trong ảnh này, mỗi tài khoản cách nhau bởi dấu phẩy "," hoặc Enter!, tối đa không quá 15 người.';
var lng_a_listfriend		= 'Danh sách bạn bè.';
var lng_close				= 'Đóng';
var lng_delete_pic			= 'Bạn có chắc chắn muốn xoá ảnh này không?';
var lng_delete_apic			= 'Xoá ảnh này';
var lng_pic_not_uploaded 	= 'Hình ảnh không tải lên';
var lng_upload_fail			= 'Tải lên thất bại';
var lng_upload_complate		= "Tải lên hoàn tất";
var lng_upload_cancel		= "Hủy bỏ tải lên";
var lng_upload_process		= 'Đã tải lên';
var lng_upload_waiting		= 'Đang chờ tải lên...';
var lng_upload_limit		= "Bạn đã đạt đến giới hạn để tải lên."
var lng_debug_upload_limit	= "Bạn chọn số lượng file vượt quá giới hạn.\n";
var lng_debug_erro_code		= 'Mã lỗi: ';
var lng_filename			= 'Tên file: ';
var lng_filezise			= 'Dung lượng: ';
var lng_content				= 'Nội dung: ';
var lng_you_can				= 'Bạn cũng có thể ';
var lng_files				= ' các tập tin';
var lng_file_is_big			= ' Tập tin quá lớn';
var lng_file_zero			= ' Tập tin vô nghĩa';
var lng_file_demit			= "Loại tập tin bị cấm.";
var lng_file_erro			= ' Lỗi loại file';
var lng_file_sel_limit		= "Bạn đã lựa chọn quá nhiều file. ";
var lng_you_can_add			= "Bạn chỉ có thể thêm ";
var lng_you_cant_add		= "Bạn không thể thêm các tập tin.";


var friendsListDatasource	= new Array();

scriptinclude = 'home_friendselector';
srcinclude = JSPATH + scriptinclude + '.js?' + VERHASH;
if(!JSLOADED[srcinclude]) {
	appendscript(srcinclude);
}

function concatJSON(json1, json2){
	for(var key in json2) {
  		json1[key] = json2[key];
 	}
 	return json1;
}
var myFSs= new Array()
var clearlist = 0;
function getUserBox(box, fs) {
	page = parseInt(box.option.pageId);
	gid = isUndefined(box.option.gid) ? -1 : parseInt(box.option.gid);
	var x = new Ajax();
	x.get('home.php?mod=spacecp&ac=friend&op=getinviteuser&inajax=1&page='+ page + '&gid=' + gid + '&' + Math.random(), function(s) {
		var data = eval('('+s+')');
		var singlenum = parseInt(data['singlenum']);
		var maxfriendnum = parseInt(data['maxfriendnum']);
		fs.addDataSource(data, clearlist);
		haveFriend = singlenum && singlenum == 20 ? true : false;
		if(singlenum && fs.allNumber < 20 && fs.allNumber < maxfriendnum && maxfriendnum > 20 && haveFriend) {
			page++;
			getUserBox(page, gid, fs);
		}
		if((typeof list_ftag !== 'undefined') && !box.binded){
			if(list_ftag[box.id]){
				for(var x in list_ftag[box.id]){
					myFSs[box.id].selectUserName(list_ftag[box.id][x]);
				}
			}
			box.binded = true;
		}
	});
}
function selectorBox(id, fs, clear, box) {
	var listObj = $('selBox_'+id);
	listObj.onscroll = function() {
		clearlist = clear ? clear : 0;
		if(this.scrollTop >= this.scrollHeight/5) {
			box.option.page++;
			box.option.gid = isUndefined(box.option.gid) ? -1 : parseInt(box.option.gid);
			if(haveFriend) {
				getUserBox(box, fs);
			}
		}
	}
	box.option.gid = isUndefined(box.option.gid) ? -1 : parseInt(box.option.gid);
	getUserBox(box, fs);
	return fs
}

var Box_act = function(id) {
	var box = new Object();
	this.loaded = false;
	box.binded = false;
	box.id = id;
	box.a1 = $('a_1_'+id);
	box.a2 = $('a_2_'+id);
	box.a3 = $('a_3_'+id);
	box.c1 = $('c_1_'+id);
	box.c11 = $('c_1_1_'+id);
	box.c2 = $('c_2_'+id);
	box.c3 = $('c_3_'+id);
	box.i1 = $('i_1_'+id);
	box.i2 = $('i_2_'+id);
	box.i3 = $('i_3_'+id);
	box.delbtn = $('ic_d_'+id);
	box.imgFriend = $('showSelectBox_'+id);
	
	box.imgFriend.onclick = function(){
		showMenu({'showid':'showSelectBox_'+id, 'duration':3, 'pos':'34!'});
		myFSs[id].showPMFriend('showSelectBox_'+id+'_menu','selectorBox_'+id, box.imgFriend);
		box.a1.click();	
	},
	box.delbtn.onclick = function(){
		if(confirm(lng_delete_pic)){
			showWindow('deletepic','home.php?mod=spacecp&ac=album&op=deletepic&picid='+id+'&handlekey=deletepic', 'get', 0);
		}
	},
	
	succeedhandle_deletepic = function(url, msg, values) {
		var liObj = 'picobj_' + values['picid'];
		var liObj = $(liObj);
		liObj.parentNode.removeChild(liObj);
	},
	
	box.c11.style.display = 'none';
	box.c1.style.display = 'none';
	box.c2.style.display = 'none';
	box.i1.style.display = 'none';
	box.i2.style.display = 'none';
	box.i3.style.display = 'none';
	box.imgFriend.style.display = 'none';
	
	box.a1.onclick = function(){
		this.className = 'bxa_btn a_1_atv';
		box.a2.className = 'bxa_btn a_2';
		box.c11.style.display = 'none';
		box.c1.style.display = 'block';
		box.c2.style.display = 'none';
		box.c3.style.display = 'none';
		box.i1.style.display = 'block';
		box.i2.style.display = 'none';
		box.i3.style.display = 'none';
		box.imgFriend.style.display = '';
		if(this.loaded != true){
			parameter = {'hasdata':id,'InputHidenName':'userpic_'+id+'[]','searchId':'i_1_'+id, 'showId':'friends_'+id, 'formId':'', 'showType':3, 'handleKey':'myFSs['+id+']', 'selBox':'selectorBox_'+id, 'selBoxMenu':'showSelectBox_'+id+'_menu', 'maxSelectNumber':'15', 'selectTabId':'a_1_'+id, 'unSelectTabId':'unSelectTab', 'maxSelectTabId':'remainNum'};
			box.option = new Object();
			box.option.page = 1;
			box.option.gid = -1;
			box.option.showNum = 0;
			box.option.haveFriend = true;
			myFSs[id] = new friendSelector(parameter);
			this.selector_Box = new selectorBox(id, myFSs[id], 0, box);
			this.loaded = true;
		}else{
			box.c11.click();	
		}
	},
	
	box.c11.onclick = box.c1.onclick = function(){
		box.c11.style.display = 'block';
		box.c1.style.display = 'none';
		box.i1.focus();
	},
	box.a2.onclick = box.c2.onclick = function(){
		box.a1.className = 'bxa_btn a_1';
		box.a2.className = 'bxa_btn a_2_atv';
		box.c11.style.display = 'none';
		box.c1.style.display = 'none';
		box.c2.style.display = 'block';
		box.c3.style.display = 'none';
		box.i1.style.display = 'none';
		box.i2.style.display = 'block';
		box.i3.style.display = 'none';
		box.imgFriend.style.display = 'none';
		box.i2.focus();
	},
	
	box.i2.onblur = box.i2.onkeyup = function(){
		var c0 = box.i2.value;
		if(c0.length > 0){
			box.c2.innerHTML = c0;
		}else{
			box.c2.innerHTML = lng_letlocation_pic;
		}
	},
	
	box.c3.onclick = box.a3.onclick = function(){
		box.a1.className = 'bxa_btn a_1';
		box.a2.className = 'bxa_btn a_2';
		box.c11.style.display = 'none';
		box.c1.style.display = 'none';
		box.c2.style.display = 'none';
		box.c3.style.display = 'none';
		box.i1.style.display = 'none';
		box.i2.style.display = 'none';
		box.i3.style.display = 'none';
		box.i3.style.display = 'block';
		box.i3.focus();
		box.imgFriend.style.display = 'none';
	},
	
	
	box.i3.onblur = function(){
		box.c3.style.display = 'block';
		box.i3.style.display = 'none';
		var c0 = box.i3.value;
		if(c0.length > 0){
			box.c3.innerHTML = c0;
		}else{
			box.c3.innerHTML = lng_letcomment_pic;
		}
	}
	return box;
}

var sdCloseTime = 2;
function preLoad() {
	if(!this.support.loading) {
		disableMultiUpload(this.customSettings);
		return false;
	}
}
function loadFailed() {
	disableMultiUpload(this.customSettings);
}
function disableMultiUpload(obj) {
	if(obj.uploadSource == 'forum' && obj.uploadFrom != 'fastpost') {
		obj.singleUpload.style.display = '';
		var dIdStr = obj.singleUpload.getAttribute("did");
		if(dIdStr != null) {
			appendscript(JSPATH + 'forum_post.js?' + VERHASH);
			var idArr = dIdStr.split("|");
			$(idArr[0]).style.display = 'none';
			if(idArr[1] == 'local') {
				switchImagebutton('local');
			} else if(idArr[1] == 'upload') {
				switchAttachbutton('upload');
			}
		}
	}
}
function fileDialogStart() {
	if(this.customSettings.uploadSource == 'forum') {
		this.customSettings.alertType = 0;
		if(this.customSettings.uploadFrom == 'fastpost') {
			appendscript(JSPATH + 'forum_post.js?' + VERHASH);
		}
	}
}
function fileQueued(file) {
	try {
		var createQueue = true;
		var progress = new FileProgress(file, this.customSettings.progressTarget);
		if(this.customSettings.uploadSource == 'forum') {
			if(this.customSettings.maxAttachNum != undefined) {
				if(this.customSettings.maxAttachNum > 0) {
					this.customSettings.maxAttachNum--;
				} else {
					this.customSettings.alertType = 6;
					createQueue = false;
				}
			}

			if(createQueue && this.customSettings.maxSizePerDay != undefined) {
				if(this.customSettings.maxSizePerDay - file.size > 0) {
					this.customSettings.maxSizePerDay = this.customSettings.maxSizePerDay - file.size
				} else {
					this.customSettings.alertType = 11;
					createQueue = false;
				}
			}
			if(createQueue && this.customSettings.filterType != undefined) {
				var fileSize = this.customSettings.filterType[file.type.substr(1).toLowerCase()];
				if(fileSize != undefined && fileSize && file.size > fileSize) {
					this.customSettings.alertType = 5;
					createQueue = false;
				}
			}

		}
		if(createQueue) {
			progress.setStatus(lng_upload_waiting);
		} else {
			this.cancelUpload(file.id);
			progress.setCancelled();
		}
		progress.toggleCancel(true, this);


	} catch (ex) {
		this.debug(ex);
	}

}

function fileQueueError(file, errorCode, message) {
	try {
		if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
			message = parseInt(message);
			showDialog(lng_debug_upload_limit+(message === 0 ? lng_upload_limit : lng_you_can + message + lng_files), 'notice', null, null, 0, null, null, null, null, sdCloseTime);
			return;
		}

		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setError();
		progress.toggleCancel(false);

		switch (errorCode) {
			case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
				progress.setStatus(lng_file_is_big);
				this.debug(lng_debug_erro_code + lng_file_is_big + ", "+ lng_filename + file.name + ", " + lng_filezise + file.size + ", " + lng_content + message);
				break;
			case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
				progress.setStatus(lng_file_zero);
				this.debug(lng_debug_erro_code + lng_file_zero + ", " + lng_filename + file.name + ", "+ lng_filezise + file.size + ", "+ lng_content + message);
				break;
			case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
				progress.setStatus(lng_file_demit);
				this.debug(lng_debug_erro_code + lng_file_erro + ", " + lng_filename + file.name + ", "+ lng_filezise + file.size + ", "+ lng_content + message);
				break;
			case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
				alert(lng_file_sel_limit +  (message > 1 ? lng_you_can_add +  message + lng_files : lng_you_cant_add));
				break;
			default:
				if (file !== null) {
					progress.setStatus("Unhandled Error");
				}
				this.debug(lng_debug_erro_code + " " + errorCode + ", " + lng_filename + file.name + ", "+ lng_filezise + file.size + ", "+ lng_content + message);
				break;
		}
	} catch (ex) {
        this.debug(ex);
    }
}

function fileDialogComplete(numFilesSelected, numFilesQueued) {
	try {
		if(this.customSettings.uploadSource == 'forum') {
			if(this.customSettings.uploadType == 'attach') {
				if(typeof switchAttachbutton == "function") {
					switchAttachbutton('attachlist');
				}
				try {
					if(this.getStats().files_queued) {
						$('attach_tblheader').style.display = '';
						$('attach_notice').style.display = '';
					}
				} catch (ex)  {}

			} else if(this.customSettings.uploadType == 'image') {
				if(typeof switchImagebutton == "function") {
					switchImagebutton('imgattachlist');
				}
				try {
					$('imgattach_notice').style.display = '';
				} catch (ex)  {}
			}
			var objId = this.customSettings.uploadType == 'attach' ? 'attachlist' : 'imgattachlist';
			var listObj = $(objId);
			var tableObj = listObj.getElementsByTagName("table");
			if(!tableObj.length) {
				listObj.innerHTML = "";
			}
		} else if(this.customSettings.uploadType == 'blog') {
			if(typeof switchImagebutton == "function") {
				switchImagebutton('imgattachlist');
			}
		}
		this.startUpload();
	} catch (ex)  {
        this.debug(ex);
	}
}

function uploadStart(file) {
	try {
		this.addPostParam('filetype', file.type);
		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setStatus(lng_upload_waiting);
		progress.toggleCancel(true, this);
		if(this.customSettings.uploadSource == 'forum') {
			var objId = this.customSettings.uploadType == 'attach' ? 'attachlist' : 'imgattachlist';
			var attachlistObj = $(objId).parentNode;
			attachlistObj.scrollTop = $(file.id).offsetTop - attachlistObj.clientHeight;
		}
	} catch (ex) {
	}

	return true;
}

function uploadProgress(file, bytesLoaded, bytesTotal) {

	try {
		var percent = Math.ceil((bytesLoaded / bytesTotal) * 100);

		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setStatus(lng_upload_process + " "+percent+" % ...");
		progress.setProgress(percent);

	} catch (ex) {
		this.debug(ex);
	}
}

function uploadSuccess(file, serverData) {
	try {
		var progress = new FileProgress(file, this.customSettings.progressTarget);
		if(this.customSettings.uploadSource == 'forum') {
			aid = parseInt(serverData);
			if(aid > 0) {
				if(this.customSettings.uploadType == 'attach') {
					ajaxget('forum.php?mod=ajax&action=attachlist&aids=' + aid + (!fid ? '' : '&fid=' + fid)+(typeof resulttype == 'undefined' ? '' : '&result=simple'), file.id);
				} else if(this.customSettings.uploadType == 'image') {
					var tdObj = getInsertTdId(this.customSettings.imgBoxObj, 'image_td_'+aid);
					ajaxget('forum.php?mod=ajax&action=imagelist&type=single&pid=' + pid + '&aids=' + aid + (!fid ? '' : '&fid=' + fid), tdObj.id);
					$(file.id).style.display = 'none';
				}
			} else {
				aid = aid < -1 ? Math.abs(aid) : aid;
				if(typeof STATUSMSG[aid] == "string") {
					progress.setStatus(STATUSMSG[aid]);
					showDialog(STATUSMSG[aid], 'notice', null, null, 0, null, null, null, null, sdCloseTime);
				} else {
					progress.setStatus(lng_upload_cancel);
				}
				this.cancelUpload(file.id);
				progress.setCancelled();
				progress.toggleCancel(true, this);
				var stats = this.getStats();
				var obj = {'successful_uploads':--stats.successful_uploads, 'upload_cancelled':++stats.upload_cancelled};
				this.setStats(obj);
			}
		} else if(this.customSettings.uploadType == 'album') {
			html = '';
			var data = eval('('+serverData+')');
			var newLI = document.createElement('li');
			newLI.className = 'li_box';
			newLI.id = 'picobj_'+data.picid;
			html += '<img src="'+data.url+'" class="boxximg" />'
			html += '<div id="c_1_'+data.picid+'" class="textareabox boxdisp1">' + lng_letinput_username+'</div>';
			html += '<div id="i_1_'+data.picid+'_menu" style="display: none;"><ul id="friends_'+data.picid+'" class="box_friend_type"></ul></div>';
			html += '<div id="c_1_1_'+data.picid+'" class="input un_selector inputuser"><input id="i_1_'+data.picid+'" class="inputf" /></div>';
			html += '<div id="c_2_'+data.picid+'" class="textareabox boxdisp2">'+ lng_letlocation_pic +'</div>';
			html += '<input class="input" id="i_2_'+data.picid+'" name="location['+data.picid+']" />';
			html += '<div id="c_3_'+data.picid+'" class="textareabox comment">'+ lng_letcomment_pic +'</div>';
			html += '<textarea name="title['+data.picid+']"  id="i_3_'+data.picid+'"></textarea>';
			html += '<div class="boxcontrol"><a href="javascript:void(0);" id="a_1_'+data.picid+'" class="bxa_btn a_1" title="'+lng_a_friend+'">0</a><a href="javascript:void(0);" id="a_2_'+data.picid+'" class="bxa_btn a_2" title="'+lng_a_location+'">&nbsp;</a><a href="javascript:void(0);"  id="a_3_'+data.picid+'" class="bxa_btn a_3" title="'+lng_a_comment+'">&nbsp;</a><a href="javascript:void(0);" class="a_delete_sel y" id="ic_d_'+data.picid+'" title="'+lng_delete_apic+'">&nbsp;</a><a class="bxa_btn y" href="javascript:void(0);" id="showSelectBox_'+data.picid+'"><img src="'+IMGDIR+'/contact-list.png"/></a></div>';
			html += '<div id="showSelectBox_'+data.picid+'_menu" class="showSelectBox_menu p_pof box_friend_selector" unselectable="on" style="display:none;">';
			html += '<div id="selBox_'+data.picid+'" class="ptn pbn selBox"><ul id="selectorBox_'+data.picid+'" class="xl xl2 cl"></ul></div>';
			html += '<div class="cl"><button type="button" class="y pn" onclick="myFSs['+data.picid+'].showPMFriend(\'showSelectBox_'+data.picid+'_menu\',\'selectorBox_'+data.picid+'\', $(\'showSelectBox_'+data.picid+'\'));doane(event)"><span>'+lng_close+'</span></button></div></div>';
			newLI.innerHTML = html;
			this.customSettings.imgBoxObj.appendChild(newLI);
			$(file.id).style.display = 'none';
			this.box_action = new Box_act(data.picid);		
			
		} else if(this.customSettings.uploadType == 'blog') {
			var data = eval('('+serverData+')');
			if(parseInt(data.picid)) {
				var tdObj = getInsertTdId(this.customSettings.imgBoxObj, 'image_td_'+data.picid);
				var img = new Image();
				img.src = data.url;
				var imgObj = document.createElement("img");
				imgObj.src = img.src;
				imgObj.className = "cur1";
				imgObj.onclick = function() {insertImage(data.bigimg);};
				tdObj.appendChild(imgObj);
				var inputObj = document.createElement("input");
				inputObj.type = 'hidden';
				inputObj.name = 'picids['+data.picid+']';
				inputObj.value= data.picid;
				tdObj.appendChild(inputObj);
			} else {
				showDialog(lng_pic_not_uploaded, 'notice', null, null, 0, null, null, null, null, sdCloseTime);
			}
			$(file.id).style.display = 'none';
		} else if(this.customSettings.uploadSource == 'portal') {
			var data = eval('('+serverData+')');
			if(data.aid) {
				if(this.customSettings.uploadType == 'attach') {
					ajaxget('portal.php?mod=attachment&op=getattach&type=attach&id=' + data.aid, file.id);
					if($('attach_tblheader')) {
						$('attach_tblheader').style.display = '';
					}
				} else {
					var tdObj = getInsertTdId(this.customSettings.imgBoxObj, 'attach_list_'+data.aid);
					ajaxget('portal.php?mod=attachment&op=getattach&id=' + data.aid, tdObj.id);
					$(file.id).style.display = 'none';
				}
			} else {
				showDialog(lng_upload_fail, 'notice', null, null, 0, null, null, null, null, sdCloseTime);
				progress.setStatus("Cancelled");
				this.cancelUpload(file.id);
				progress.setCancelled();
				progress.toggleCancel(true, this);
			}
		} else {
			progress.setComplete();
			progress.setStatus(lng_upload_complate);
			progress.toggleCancel(false);
		}
	} catch (ex) {
		this.debug(ex);
	}
}

function getInsertTdId(boxObj, tdId) {
	var tableObj = boxObj.getElementsByTagName("table");
	var tbodyObj, trObj, tdObj;
	if(!tableObj.length) {
		tableObj = document.createElement("table");
		tableObj.className = "imgl";
		tbodyObj = document.createElement("TBODY");
		tableObj.appendChild(tbodyObj);
		boxObj.appendChild(tableObj);

	} else if(!tableObj[0].getElementsByTagName("tbody").length) {
		tbodyObj = document.createElement("TBODY");
		tableObj.appendChild(tbodyObj);
	} else {
		tableObj = tableObj[0];
		tbodyObj = tableObj.getElementsByTagName("tbody")[0];
	}

	var createTr = true;
	var inserID = 0;
	if(tbodyObj.childNodes.length) {
		trObj = tbodyObj.childNodes[tbodyObj.childNodes.length -1];
		var findObj = trObj.getElementsByTagName("TD");
		for(var j=0; j < findObj.length; j++) {
			if(findObj[j].id == "") {
				inserID = j;
				tdObj = findObj[j];
				break;
			}
		}
		if(inserID) {
			createTr = false;
		}
	}
	if(createTr) {
		trObj = document.createElement("TR");
		for(var i=0; i < 4; i++) {
			var newTd = document.createElement("TD");
			newTd.width = "25%";
			newTd.vAlign = "bottom";
			newTd.appendChild(document.createTextNode(" "));
			trObj.appendChild(newTd);
		}
		tdObj = trObj.childNodes[0];
		tbodyObj.appendChild(trObj);
	}
	tdObj.id = tdId;
	return tdObj;
}
function uploadComplete(file) {
	try {
		if (this.getStats().files_queued === 0) {
		} else {
			this.startUpload();
		}
	} catch (ex) {
		this.debug(ex);
	}

}

function uploadError(file, errorCode, message) {
	try {
		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setError();
		progress.toggleCancel(false);

		switch (errorCode) {
			case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
				progress.setStatus("Upload Error: " + message);
				this.debug(lng_debug_erro_code + " HTTP Error, File name: " + file.name + ", Message: " + message);
				break;
			case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
				progress.setStatus("Configuration Error");
				this.debug(lng_debug_erro_code + " No backend file, File name: " + file.name + ", Message: " + message);
				break;
			case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
				progress.setStatus("Upload Failed.");
				this.debug(lng_debug_erro_code + " Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
				break;
			case SWFUpload.UPLOAD_ERROR.IO_ERROR:
				progress.setStatus("Server (IO) Error");
				this.debug(lng_debug_erro_code + " IO Error, File name: " + file.name + ", Message: " + message);
				break;
			case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
				progress.setStatus("Security Error");
				this.debug(lng_debug_erro_code + " Security Error, File name: " + file.name + ", Message: " + message);
				break;
			case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
				progress.setStatus("Upload limit exceeded.");
				this.debug(lng_debug_erro_code + " Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
				break;
			case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:
				progress.setStatus("File not found.");
				this.debug(lng_debug_erro_code + " The file was not found, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
				break;
			case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
				progress.setStatus("Failed Validation.  Upload skipped.");
				this.debug(lng_debug_erro_code + " File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
				break;
			case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
				if (this.getStats().files_queued === 0) {
				}
				progress.setStatus(this.customSettings.alertType ? STATUSMSG[this.customSettings.alertType] : "Cancelled");
				progress.setCancelled();
				break;
			case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
				progress.setStatus("Stopped");
				break;
			default:
				progress.setStatus("Unhandled Error: " + error_code);
				this.debug(lng_debug_erro_code + " " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
				break;
		}
	} catch (ex) {
        this.debug(ex);
    }
}